﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.ComponentModel;

namespace FortuneHeavenCommon.ComMethod
{
    public class UtilMethod
    {
        public static bool CheckString(string input)
        {
            int value = 0;
            if (!string.IsNullOrEmpty(input) && !string.IsNullOrEmpty(input.Trim()))
            {
                for (int index = 0; index < input.Length; index++)
                {
                    value = (int)input[index];
                    if ((value != 44) && value < 48 || value > 57)
                    {
                        return false;
                    }
                }
            }
            return true;
        }

        public static string GetDescription(System.Enum value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            string description = value.ToString();
            FieldInfo fieldInfo = value.GetType().GetField(description);
            DescriptionAttribute[] attributes = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);

            if (attributes != null && attributes.Length > 0)
            {
                description = attributes[0].Description;
            }
            return description;
        }
        /// <summary>
        /// 获取时间格式。
        /// </summary>
        /// <param name="count"></param>
        /// <returns></returns>
        public static string GetTimeByInt(object count)
        {
            int k =0;
            if (count is int)
            { 
                k  = (int)count;
            }
            TimeSpan f = new TimeSpan((long)k * 10000000);
            return f.Days + "天" + f.Hours + "小时" + f.Minutes + "分钟";
        }
    }
}
